package com.meiya.baseweb.action;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.interceptor.SessionAware;
import org.springframework.stereotype.Controller;

import com.meiya.baseweb.entity.Pubopinion;
import com.meiya.baseweb.service.IPublicOpinionViewService;
import com.opensymphony.xwork2.ActionSupport;

@Controller
public class PubopionAction extends ActionSupport implements SessionAware {

	int id;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1989616397617774722L;
	private Map<String, Object> session;
    public void setSession(Map<String, Object> session) {
        this.session = session;
    }
	private Pubopinion pub;
	
	@Resource
	private IPublicOpinionViewService pubService;

	public Pubopinion getPub() {
		return pub;
	}
	public void setPub(Pubopinion pub) {
		this.pub = pub;
	}
	public String execute() throws Exception {
		if(session.get("isLogin")!=null&&session.get("isLogin").equals(true)){
			pubService.addNewPublicOpinion(pub);
		}
		return SUCCESS;
	}
	public String test() throws Exception {
		System.out.println(2);
		this.setId(999);
		return "test";
	}
	public String deletePubopion() throws Exception {
		pub=pubService.getSinglePubopinion("id_I_1_EQ__");

		pub.setDomain(this.id+"main");
		this.setId(999);
		return SUCCESS;
	}
}
